#include <bits/stdc++.h>
using namespace std;

int main() {
    int n, m, t;
    int arr[25][25];
    cin >> n >> m;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            cin >> arr[i][j];
    cin >> t;
    while (t--) {
        int k, x, y;
        cin >> k >> x >> y;
        if (k == 1)
            for (int i = 1; i <= n; ++i)
                swap(arr[i][x], arr[i][y]);
        else
            swap(arr[x], arr[y]);
    }

    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j)
            cout << arr[i][j] << ' ';
        cout << endl;
    }
    return 0;
}